package com.lwx.leetcode.offer.middile;


import java.util.ArrayList;
import java.util.List;

public class Offer45 {
    private List<String> ret;
    private boolean[]  used;

    public String minNumber(int[] nums) {
        if(nums == null){
            return null;
        }
        ret = new ArrayList<>();
        used = new boolean[nums.length];
        List<Integer> p = new ArrayList<>();
        generateOnePremes(nums,0, p);
        
        return null;
    }

    public void generateOnePremes(int[] nums, int index, List<Integer> p){

        if(nums.length == index-1){
            ArrayList list = new ArrayList<>(p);
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < list.size(); i++) {
                sb.append(i);
            }
            ret.add(sb.toString());
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if(!used[i]){
                used[i] = true;
                p.add(nums[i]);
                generateOnePremes(nums,i+1, p);
                p.remove(i);
                used[i] = false;
            }
        }
    }
}
